String.prototype.endWith = function(t) {
    var e = this.length - t.length;
    return e >= 0 && this.lastIndexOf(t) == e;
};

var t = getApp();

Page({
    data: {
        liveList: [],
        heightauto: "auto",
        widthauto: "auto",
        minStyle: !0,
        screeheight: 0,
        myvideo: "",
        rid: "",
        showVideo: "",
        showName: "",
        curr: ""
    },
    onLoad: function(e) {
        this.data.myvideo = wx.createVideoContext("myvideo"), this.getinformation(), e.rid && this.setData({
            rid: e.rid,
            showName: e.name
        }), e.mid && t._setMid(e.mid);
    },
    onReady: function() {},
    onShow: function() {
        this.getRoom();
    },
    chooseItem: function(t) {
        this.setData({
            curr: t.currentTarget.dataset.index,
            showVideo: this.data.liveList[t.currentTarget.dataset.index].media_url
        });
    },
    getRoom: function() {
        var e = this, i = t.getNetAddresss("plugin.appletslive.frontend.controllers.live.getReplay");
        i += "&rid=" + this.data.rid, t._getNetWork({
            url: i,
            success: function(t) {
                var i = t.data;
                if (1 == i.result) {
                    for (var a = [], o = 0; o < i.data.live_replay.length; o++) i.data.live_replay[o].media_url.endWith("m3u8") || a.push(i.data.live_replay[o]);
                    a.length >= 1 ? e.setData({
                        liveList: a,
                        curr: 0,
                        showVideo: a[0].media_url
                    }) : wx.showToast({
                        title: "当前房间号没有回放",
                        icon: "none",
                        duration: 2e3
                    });
                } else console.log(i.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getinformation: function() {
        try {
            var t = wx.getSystemInfoSync(), e = t.windowHeight, i = t.windowWidth;
            this.setData({
                heightauto: e + "px",
                widthauto: i + "px"
            }), this.data.screeheight = e;
        } catch (t) {}
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareTimeline: function() {
        var t = wx.getStorageSync("yz_uid"), e = "";
        return t && (e = t), {
            query: "rid=" + this.data.rid + "&name=" + this.data.showName + "&mid=" + e
        };
    },
    onShareAppMessage: function() {
        var t = wx.getStorageSync("yz_uid"), e = "";
        t && (e = t);
        return {
            title: "直播回放",
            path: "/packageD/playBack/playBack?rid=+" + this.data.rid + "+&name=" + this.data.showName + "&mid=" + e,
            success: function(t) {
                console.info(t + "成功");
            },
            fail: function(t) {
                console.log(t + "失败");
            }
        };
    }
});